home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / programs / bug2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-29  |  1.4 KB  |  57 lines

  1.  
  2. /*
  3.  * A compound string shows differently in CSText and Label
  4.  *
  5.  * Apologies for the "segment" based nature of the XmString 
  6.  * creation - it was all I could do under Motif 1.2
  7.  */
  8.  
  9. #include <Xm/Label.h>
  10. #include <Xm/CSText.h>
  11. #include <Xm/RowColumn.h>
  12.  
  13. int
  14. main(argc, argv)
  15.     int argc;
  16.     char **argv;
  17. {
  18.     Widget rowcol;
  19.     Widget button;
  20.     XtAppContext app;
  21.     Widget toplevel;
  22.     Widget cstext;
  23.     XmString str1, str2, str3;
  24.     Arg args[10];
  25.     int n = 0;
  26.     XmStringCharSet    charSet = XmFONTLIST_DEFAULT_TAG;
  27.  
  28.     toplevel = XtAppInitialize(&app, "XmSend", NULL, 0, &argc, argv,
  29.                 NULL, NULL, 0);
  30.  
  31.     rowcol = XmCreateRowColumn(toplevel, "rowcol", NULL, 0);
  32.     XtManageChild(rowcol);
  33.  
  34.     button = XmCreateLabel(rowcol, "top_button", args, n);
  35.     XtManageChild(button);
  36.  
  37.     n = 0;
  38.     XtSetArg(args[n], XmNrows, 5); n++;
  39.     XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  40.     cstext = XmCreateCSText(rowcol, "text", args, n);
  41.     XtManageChild(cstext);
  42.  
  43.     str1 = XmStringSegmentCreate("hi there", charSet, 
  44.             XmSTRING_DIRECTION_L_TO_R, True);
  45.  
  46.     str2 = XmStringSegmentCreate("back again", charSet, 
  47.             XmSTRING_DIRECTION_R_TO_L, False);
  48.     str3 = XmStringConcatAndFree(str1, str2);
  49.  
  50.     XtVaSetValues(button, XmNlabelString, str3, NULL);
  51.     XtVaSetValues(cstext, XmNcstextValue, str3, NULL);
  52.  
  53.     XtRealizeWidget(toplevel);
  54.  
  55.     XtAppMainLoop(app);
  56. }
  57.